package com.doctcloud.datacloud.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.doctcloud.common.core.annotation.Excel;
import com.doctcloud.common.core.annotation.NotZero;
import lombok.*;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;

import static com.doctcloud.common.core.utils.StringUtils.trim;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@EqualsAndHashCode(of = {"patientId","visitId","itemNo"})
@TableName("inp_bill_detail")
public class InpBillDetailEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    @Excel(name = "患者ID")
    @NotBlank(message = "患者ID不得为空")
    private String patientId;
    @Excel(name = "住院标识")
    @NotZero(message = "住院标识不得为空或为零")
    private Integer visitId;
    @Excel(name = "序号")
    @NotZero(message = "就诊序号不得为空或0")
    private Integer itemNo;
    @Excel(name = "项目类别")
    @NotBlank(message = "收费类别不得为空")
    private String itemClass;
    @Excel(name = "项目代码")
    @NotBlank(message = "项目代码不得为空")
    private String itemCode;
    @Excel(name = "项目名称")
    private String itemName;
    @Excel(name = "项目规格")
    @NotBlank(message = "项目规格不得为空")
    private String itemSpec;
    @Excel(name = "数量")
    @NotZero(message = "数量不得为空或为零")
    private Integer amount;
    @Excel(name = "单位")
    private String units;
    @Excel(name = "开单科室代码")
    private String orderedBy;
    @Excel(name = "执行科室代码")
    private String performedBy;
    @Excel(name = "计价费用")
    private Double costs;
    @Excel(name = "应收费用")
    private Double charges;
    @Excel(name = "计价时间")
    private Date billingDateTime;
    @Excel(name = "结帐号")
    private String rcptNo;
    @Data
    public static class Key {
        private final String patientId;
        private final Integer visitId;
        private final Integer itemNo;

        public Key(String patientId, Integer visitId, Integer itemNo) {
            this.patientId = patientId;
            this.visitId = visitId;
            this.itemNo = itemNo;
        }
    }

    public void setItemName(String itemName) {
        this.itemName = trim(itemName);
    }

    public void setPatientId(String patientId) {
        this.patientId = trim(patientId);
    }

    public void setItemClass(String itemClass) {
        this.itemClass = trim(itemClass);
    }

    public void setItemCode(String itemCode) {
        this.itemCode = trim(itemCode);
    }

    public void setItemSpec(String itemSpec) {
        this.itemSpec = trim(itemSpec);
    }

    public void setUnits(String units) {
        this.units = trim(units);
    }

    public void setOrderedBy(String orderedBy) {
        this.orderedBy = trim(orderedBy);
    }

    public void setPerformedBy(String performedBy) {
        this.performedBy = trim(performedBy);
    }

    public void setRcptNo(String rcptNo) {
        this.rcptNo = trim(rcptNo);
    }
}
